#encoding=utf-8

from collections import OrderedDict

d = OrderedDict()
d['foo'] = 1
d['bar'] = 2
d['spam'] = 3
d['foo'] = 4
for key,value in d.items():
    print value

import json
json_d = json.dumps(d)
print json_d

print '对比'
d2 = {}
d2['foo'] = 1
d2['bar'] = 2
d2['spam'] = 3
d2['foo'] = 4
for key,value in d2.items():
    print value

import json
json_d2 = json.dumps(d2)
print json_d2

min_num = min(zip(d.values(),d.keys()))
print min_num
num_sorted = sorted(zip(d.values(), d.keys()))
print num_sorted


a = [8,1,2,2,1,3,4,4,3,6,7]
print list(set(a))

def dedupe(items,key=None):
    seem = set()
    for item in items:
        val = item if key is None else key(item)
        if item not in seem:
            yield item
            seem.add(item)


print list(dedupe(a))


from collections import Counter
word_counts = Counter(a)
top_three = word_counts.most_common(3)
print top_three




